<?php

namespace Website\Modules\Backend\Controllers;

class IndexController extends ControllerBase
{
    public function indexAction()
    {
        echo 'this is index';
    }

    public function testAction()
    {
        echo 'Hello World!';
    }

    public function test1Action()
    {
        $a = $this->request->get('a');
        var_dump("a: $a");
    }

    public function test2Action($a='',$b='')
    {
        $aa = $this->request->get('a');
        var_dump($a.'0------------1');
        print_r($aa);
    }
    
    //测试输出
    public function test3Action()
    {
        return $this->response->setJsonContent([
            'code'  =>  1,
            'message'   =>  'success',
        ]);
    }
    //页面跳转
    public function test4Action()
    {
        return $this->response->redirect('http://baidu.com');
    }

    //此种方式的页面跳转不会改变URL地址，只是将请求转发到另一个控制器的action。
    public function test5Action()
    {
        return $this->dispatcher->forward([
            'controller'    =>  'index',
            'action'        =>  'index',
        ]);
    }

    public function test6Action()
    {
        //var_dump($this->session);
        //var_dump($this->cookies);
        var_dump($this->request);
        var_dump($this->response);
        var_dump($this->db);
        var_dump($this->logger);
    }

    public function test7Action()
    {
        $this->view->pick('index/index');
    }
}

